﻿/* Open source distributed without warranties of any kind. */

namespace Transcriber.Api
{
    #region Using
    using System.Windows.Forms;
    #endregion

    /// <summary>
    /// Base class of objects that implement <see cref="ITranscriberPlugin"/>
    /// </summary>
    public abstract class TranscriberPlugin : Disposable, ITranscriberPlugin
    {
        private ITranscriberApplication mTranscriber;

        /// <summary>
        /// Gets the <see cref="ITranscriberApplication"/> that is accessed by
        /// this plug-in object.
        /// </summary>
        /// <value>
        /// The <see cref="ITranscriberApplication"/> that is accessed by
        /// this plug-in object.
        /// </value>
        public ITranscriberApplication Transcriber
        {
            get { return this.mTranscriber; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TranscriberPlugin"/> class.
        /// </summary>
        /// <param name="transcriber">The transcriber.</param>
        protected TranscriberPlugin(ITranscriberApplication transcriber)
        {
            this.mTranscriber = transcriber;
        }

        /// <summary>
        /// Gets the name of this plug-in object.
        /// </summary>
        /// <value>The name.</value>
        public virtual string Name
        {
            get { return this.GetType().Name; }
        }

        /// <summary>
        /// Transforms the given <paramref name="text"/>.
        /// </summary>
        /// <param name="text">The source text.</param>
        /// <returns>The transformed text.</returns>
        public abstract string Transcribe(string text);

        /// <summary>
        /// Gets the settings dialog.
        /// </summary>
        /// <returns>The settings dialog.</returns>
        public virtual Form GetSettingsDialog()
        {
            return null;
        }

        /// <summary>
        /// Gets the destination context menu items.
        /// </summary>
        /// <returns>The destination context menu items.</returns>
        public virtual ToolStripItem[] GetDestinationContextMenuItems()
        {
            return null;
        }

        /// <summary>
        /// Gets the source context menu items.
        /// </summary>
        /// <returns>The source context menu items.</returns>
        public virtual ToolStripItem[] GetSourceContextMenuItems()
        {
            return null;
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return this.Name;
        }
    }
}